how to validate the input fields in onclick function